package cn.tedu.resultmapdemo.mapper;


import cn.tedu.resultmapdemo.pojo.Teacher;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface TeacherMapper {
    /**
     * Mybatis要求接口中的方法有如下规则:
     * ①方法名: 要求见名知意
     * ②方法返回值: 执行的SQL返回的结果,按照情况封装
     * ·查询的结果是一条记录,那么直接封装到实例中记录
     * ·查询的结果是多条记录,那么封装到List<封装的类型>
     * ·执行的SQL返回的是修改的记录数,那么可以设置int
     * ·执行的SQL不需要返回内容,设置为void
     * ③方法的参数: 后面再说
     */
    @Select("SELECT * FROM teacher")
    public List<Teacher> getTeacherAll();

    @Insert("INSERT INTO teacher VALUES(6666,'光头师傅',22,'宗师',null,100000,50000,'男',0);")
    public int addTeacher();

    @Update("UPDATE teacher SET salary = 1000 WHERE name = '光头师傅'")
    public int updateTeacher();

    //删除光头师傅这条数据
    @Delete("DELETE FROM teacher WHERE name = '光头师傅'")
    public int deleteTeacher();

    public Teacher getTeacherById(Integer id);

    public Teacher getTeacherSubjectById(Integer id);
}
